<?php
session_start();
require_once '../header.php';
if (!isset($_SESSION['uid'])) {
    ?>
    <script>window.location.href = "./login.php";</script>
    <?php
}

?>
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>海报后台首页</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <script src="assets/js/echarts.min.js"></script>

    <script>
        function adapte() {//适配
            var designWidth = 1080, rem2px = 100;
            document.documentElement.style.fontSize = window.innerWidth / designWidth * rem2px + "px";
        }
        adapte();
    </script>
</head>

<body data-type="index">


<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <a href="javascript:;" class="tpl-logo">
            <img src="assets/img/logo.png" alt="">
        </a>
    </div>
    <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right">

    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
                class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span class="am-icon-bell-o"></span> 新消息 <span
                            class="am-badge tpl-badge-success am-round">5</span></span>
                </a>
                <ul class="am-dropdown-content tpl-dropdown-content">
                    <li class="tpl-dropdown-content-external">
                        <h3>你有 <span class="tpl-color-success">5</span> 条新消息</h3><a href="###">全部</a></li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                    class="am-icon-btn am-icon-plus tpl-dropdown-ico-btn-size tpl-badge-success"></span>
                            【预览模块】移动端 查看时 手机、电脑框隐藏。</a>
                        <span class="tpl-dropdown-list-fr">3小时前</span>
                    </li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                    class="am-icon-btn am-icon-check tpl-dropdown-ico-btn-size tpl-badge-danger"></span>
                            移动端，导航条下边距处理</a>
                        <span class="tpl-dropdown-list-fr">15分钟前</span>
                    </li>
                    <li class="tpl-dropdown-list-bdbc"><a href="#" class="tpl-dropdown-list-fl"><span
                                    class="am-icon-btn am-icon-bell-o tpl-dropdown-ico-btn-size tpl-badge-warning"></span>
                            追加统计代码</a>
                        <span class="tpl-dropdown-list-fr">2天前</span>
                    </li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen" class="tpl-header-list-link"><span
                            class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>

            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                    <span class="tpl-header-list-user-nick"><?= $_SESSION['username'] ?></span><span
                            class="tpl-header-list-user-ico"> <img
                                src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="#"><span class="am-icon-bell-o"></span> 资料</a></li>
                    <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                    <li><a href="#"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li>
                <a href="###" class="tpl-header-list-link" onclick="logout()">
                    <span class="am-icon-sign-out tpl-header-list-ico-out-size">
                    </span>
                </a>
            </li>
        </ul>
    </div>
</header>


<div class="tpl-page-container tpl-page-header-fixed">


    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-title">
            功能列表
        </div>
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="index.php" class="nav-link active">
                        <i class="am-icon-home"></i>
                        <span>首页</span>
                    </a>
                </li>

                <li class="tpl-left-nav-item">
                    <a href="javascript:;" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-table"></i>
                        <span>表格</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <a href="table-font-list.php">
                                <i class="am-icon-angle-right"></i>
                                <span>文字表格</span>
                                <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                            </a>

                            <a href="table-images-list.php">
                                <i class="am-icon-angle-right"></i>
                                <span>图片表格</span>
                                <i class="tpl-left-nav-content tpl-badge-success">
                                    18
                                </i>
                            </a>
                            <a href="form-news.php">
                                <i class="am-icon-angle-right"></i>
                                <span>消息列表</span>
                                <i class="tpl-left-nav-content tpl-badge-primary">
                                    5
                                </i>
                            </a>
                        </li>
                    </ul>
                </li>

                <li class="tpl-left-nav-item">
                    <a href="login.php" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-key"></i>
                        <span>登录</span>

                    </a>
                </li>
            </ul>
        </div>
    </div>


    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            <?php
            if (isset($_SESSION['username'])) {
                echo $_SESSION['username'];
            }
            ?>
        </div>
        <ol class="am-breadcrumb">
            <li><a href="./index.php" class="am-icon-home">首页</a></li>
        </ol>
        <div class="tpl-content-scope">
            <div class="note note-info">
                <h3>海报制作后台管理
                    <span class="close" data-close="note"></span>
                </h3>
                <p></p>
                <p><span class="label label-danger">提示:</span>
                </p>
            </div>
        </div>

        <div class="row">
            <div class="am-u-lg-3 am-u-md-6 am-u-sm-12">
                <div class="dashboard-stat blue">
                    <div class="visual">
                        <i class="am-icon-comments-o"></i>
                    </div>
                    <div class="details">
                        <div class="number">
                            <?php
                            require_once './core/admin-sql.php';
                            $sql = new AdminSql();
                            $result_array = $sql->searchAllUidForms($_SESSION['uid']);
                            echo $result_array[0];
                            ?>
                        </div>
                        <div class="desc">
                            我的表格
                        </div>
                    </div>
                    <a class="more" href="./table-font-list.php"> 查看更多
                        <i class="m-icon-swapright m-icon-white"></i>
                    </a>
                </div>
            </div>
            <div class="am-u-lg-3 am-u-md-6 am-u-sm-12">
                <div class="dashboard-stat red">
                    <div class="visual">
                        <i class="am-icon-bar-chart-o"></i>
                    </div>
                    <div class="details">
                        <div class="number">
                            <?php
                            $result_array_answer = $sql->searchAllUidTidForms($_SESSION['uid'], 0);
                            echo $result_array_answer[0];
                            ?>
                        </div>
                        <div class="desc">
                            填写的表格
                        </div>
                    </div>
                    <a class="more" href="./table-font-list.php"> 查看更多
                        <i class="m-icon-swapright m-icon-white"></i>
                    </a>
                </div>
            </div>
            <div class="am-u-lg-3 am-u-md-6 am-u-sm-12"></div>
            <div class="am-u-lg-3 am-u-md-6 am-u-sm-12"></div>

        </div>

        <div class="row">
            <div class="am-u-md-6 am-u-sm-12 row-mb">
                <div class="tpl-portlet">
                    <div class="tpl-portlet-title">
                        <div class="tpl-caption font-green ">
                            <span>新消息</span>
                        </div>

                    </div>

                    <div class="am-tabs tpl-index-tabs" data-am-tabs>
                        <ul class="am-tabs-nav am-nav am-nav-tabs">
                            <li class="am-active"><a href="#tab1">填写的</a></li>
                            <li><a href="#tab2">创建的</a></li>
                        </ul>

                        <div class="am-tabs-bd">
                            <div class="am-tab-panel am-fade am-in am-active" id="tab1">
                                <div id="wrapperA" class="wrapper">
                                    <div id="scroller" class="scroller">
                                        <ul class="tpl-task-list tpl-task-remind">
                                            <?php
                                            $result_array = $sql->searchAddEditForm($_SESSION['uid'], 5);
                                            $time = time();
                                            for ($i = 0; $i < $result_array[0]; $i++){
                                                ?>
                                                <li>
                                                    <div class="cosB">
                                                        <?php
                                                        $c_time = $result_array[1][$i][2];
                                                        $a_time = $time - $c_time;
                                                        if ($a_time > 86400) {
                                                            $b_time = floor($a_time / 86400);
                                                            echo "{$b_time}天前";
                                                        } elseif ($a_time > 3600) {
                                                            $b_time = floor($a_time / 3600);
                                                            echo "{$b_time}小时前";
                                                        } elseif ($a_time > 60) {
                                                            $b_time = floor($a_time / 60);
                                                            echo "{$b_time}分钟前";
                                                        } elseif ($a_time > 0) {
                                                            echo "{$a_time}秒前";
                                                        }
                                                        ?>
                                                    </div>
                                                    <div class="cosA">
                                                        <span class="cosIco">
                        <i class="am-icon-bell-o"></i>
                      </span>
                                                        <span>
                                                            <?php
                                                            echo "{$result_array[1][$i][0]}填写了您的报名表【{$result_array[1][$i][1]}】";
                                                            ?><a href="../showForm.php?cid=<?= $_SESSION['uid'] ?>&pid=<?= $result_array[1][$i][1] ?>&uid=<?= $result_array[1][$i][0] ?>" target="_blank"> <span
                                                                    class="tpl-label-info"> 查看表格
                                                            <i class="am-icon-share"></i>
                                                        </span></a></span>
                                                    </div>
                                                </li>
                                            <?php
                                            }
                                            ?>

                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="am-tab-panel am-fade" id="tab2">
                                <div id="wrapperB" class="wrapper">
                                    <div id="scroller" class="scroller">
                                        <ul class="tpl-task-list tpl-task-remind">
                                            <?php
                                            $result_array = $sql->searchNewForm($_SESSION['uid'], 5);
                                            $time = time();
                                            for ($i = 0; $i < $result_array[0]; $i++) {
                                                ?>
                                                <li>
                                                    <div class="cosB">
                                                        <?php
                                                        $c_time = $result_array[1][$i][1];
                                                        $a_time = $time - $c_time;
                                                        if ($a_time > 86400) {
                                                            $b_time = floor($a_time / 86400);
                                                            echo "{$b_time}天前";
                                                        } elseif ($a_time > 3600) {
                                                            $b_time = floor($a_time / 3600);
                                                            echo "{$b_time}小时前";
                                                        } elseif ($a_time > 60) {
                                                            $b_time = floor($a_time / 60);
                                                            echo "{$b_time}分钟前";
                                                        } elseif ($a_time > 0) {
                                                            echo "{$a_time}秒前";
                                                        }
                                                        ?>
                                                    </div>
                                                    <div class="cosA">
                                                        <span class="cosIco">
                        <i class="am-icon-bell-o"></i>
                      </span>

                                                        <span> 您创建了【<?= $result_array[1][$i][0] ?>】报名表 <a href="../form.php?uid=<?= $_SESSION['uid'] ?>&fid=<?= $result_array[1][$i][0] ?>" target="_blank"><span
                                                                    class="tpl-label-info">  查看报名表
                                                            <i class="am-icon-share"></i>
                                                        </span></a></span>
                                                    </div>
                                                </li>
                                                <?php
                                            }
                                            ?>

                                        </ul>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

                </div>
            </div>
        </div>


    </div>

</div>


<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="./ajax/ajax-post.js"></script>
</body>

</html>

<?php
require_once '../footer.php';